/**
* Rangeslider
*/
@use 'sass:math';

.rangeslider {
  margin: 0 var(--spacing-quarter-unit);
  min-width: 60px;
  position: relative;
  background: var(--color-background-light);
  touch-action: none;
  border: 1px solid var(--color-border-default);
  flex-grow: 1;

  &,
  .rangeslider__fill {
    display: block;
  }
  .rangeslider__handle {
    outline: 0;
    background: #fff;
    border: 1px solid var(--color-border-default);
    cursor: pointer;
    display: inline-block;
    position: absolute;
    .rangeslider__active {
      opacity: 1;
    }
  }

  .rangeslider__handle-tooltip {
    $size: 20px;
    width: $size;
    height: $size;
    text-align: center;
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    font-weight: normal;
    font-size: 14px;
    transition: all 100ms ease-in;
    border-radius: 4px;
    display: inline-block;
    color: white;
    left: 50%;
    transform: translate3d(-50%, 0, 0);
    span {
      margin-top: 12px;
      display: inline-block;
      line-height: 100%;
    }
    &:after {
      content: ' ';
      position: absolute;
      width: 0;
      height: 0;
    }
  }
}

/**
* Rangeslider - Horizontal slider
*/
.rangeslider-horizontal {
  height: 6px;
  border-radius: 10px;
  .rangeslider__fill {
    height: 100%;
    background-color: var(--color-accent);
    border: var(--border-accent);
    border-radius: 10px;
    transform: translateY(-1px);
    top: 0;
  }
  .rangeslider__handle {
    $size: 20px;
    width: math.div($size, 3);
    height: $size * 1.5;
    border-radius: $size;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    &:after {
      content: ' ';
      position: absolute;
      width: $size * 0.2;
      height: $size;
      border-radius: $size * 0.25;
      background-color: var(--color-accent);
      display: none;
    }
  }
  .rangeslider__handle-tooltip {
    top: -55px;
    &:after {
      border-left: 8px solid transparent;
      border-right: 8px solid transparent;
      border-top: 8px solid rgba(0, 0, 0, 0.8);
      left: 50%;
      bottom: -8px;
      transform: translate3d(-50%, 0, 0);
    }
  }
}

/**
* Rangeslider - Vertical slider
*/
.rangeslider-vertical {
  margin: 20px auto;
  height: 150px;
  max-width: 10px;
  background-color: transparent;

  .rangeslider__fill,
  .rangeslider__handle {
    position: absolute;
  }

  .rangeslider__fill {
    width: 100%;
    background-color: #7cb342;
    box-shadow: none;
    bottom: 0;
  }
  .rangeslider__handle {
    width: 30px;
    height: 10px;
    left: -10px;
    box-shadow: none;
  }
  .rangeslider__handle-tooltip {
    left: -100%;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
    &:after {
      border-top: 8px solid transparent;
      border-bottom: 8px solid transparent;
      border-left: 8px solid rgba(0, 0, 0, 0.8);
      left: 100%;
      top: 12px;
    }
  }
}

/**
* Rangeslider - Reverse
*/

.rangeslider-reverse {
  &.rangeslider-horizontal {
    .rangeslider__fill {
      right: 0;
    }
  }
  &.rangeslider-vertical {
    .rangeslider__fill {
      top: 0;
      bottom: inherit;
    }
  }
}

/**
* Rangeslider - Labels
*/
.rangeslider__labels {
  position: relative;
  .rangeslider-vertical & {
    position: relative;
    list-style-type: none;
    margin: 0 0 0 24px;
    padding: 0;
    text-align: left;
    width: 250px;
    height: 100%;
    left: 10px;

    .rangeslider__label-item {
      position: absolute;
      transform: translate3d(0, -50%, 0);

      &::before {
        content: '';
        width: 10px;
        height: 2px;
        background: black;
        position: absolute;
        left: -14px;
        top: 50%;
        transform: translateY(-50%);
        z-index: -1;
      }
    }
  }

  .rangeslider__label-item {
    position: absolute;
    font-size: 14px;
    cursor: pointer;
    display: inline-block;
    top: 10px;
    transform: translate3d(-50%, 0, 0);
  }
}
